package controller

import (
	"Short_chain_cats/user/service"
	"fmt"

	"github.com/gin-gonic/gin"
)

func SendShortChainEmail(ctx *gin.Context, msg string) error {
	userIDAny, _ := ctx.Get("userID")
	// 尝试将 userID 断言为 int 类型
	userID, ok := userIDAny.(int)
	if !ok {
		// 如果断言失败，返回错误
		return fmt.Errorf("userID断言失败,类型为%T", userIDAny)
	}
	if err := service.GetEmailById(ctx, userID, msg); err != nil {
		return err
	}
	return nil
}
